package com.smartwebx.ha.web.admin.module.screen.report;

import java.sql.CallableStatement;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

import oracle.jdbc.OracleCallableStatement;

import com.smartwebx.ha.dal.assign.bean.HaUser;
import com.smartwebx.ha.web.admin.common.util.HaTool;

public class ProceTest {
	public static void main(String[] args) throws Exception {
		ProceTest p = new ProceTest();
		p.hehe("2014-07-01 00:00:00", "2014-09-01 00:00:00", "63309200,60111300");
	}
	public List<HaUser> hehe(String startTime, String endTime, String stcd){
        Connection conn = null;
        CallableStatement statement = null;
        ResultSet rs = null;
        List<HaUser> users = null;
        
        startTime = HaTool.string2Date(startTime);
        endTime = HaTool.string2Date(endTime);
        
        try {
        	ConnUtils connUtils = new ConnUtils();
            conn = connUtils.getConnection();
            statement = conn.prepareCall("{?=call JSSFK.JMAXNDRT(?,?,?)}");
            statement.registerOutParameter(1, oracle.jdbc.OracleTypes.CURSOR);
            statement.setString(2, stcd);
            statement.setString(3, startTime);
            statement.setString(4, endTime);
            statement.executeUpdate();
            rs = ((OracleCallableStatement) statement).getCursor(1);
            users = new ArrayList<HaUser>();
            while (rs.next()) {
    			HaUser haUser = new HaUser();
    			haUser.setEmail(rs.getString(1));
    			haUser.setName(rs.getString(2));
    			haUser.setMobile(rs.getString(3));
    			users.add(haUser);
    		}
        } catch (SQLException e) {
            e.printStackTrace();
        }finally{
            ConnUtils.free(rs, statement, conn);
        }
		return users;
	}
}